namespace hjc {

	export class AoiSystem extends System {

		protected $concerns = [Aoi];
		protected execute(entities: Entity[], param: TimeParam): void {
			let camera = game.camera;
			entities.forEach(entity => {
				let [aoi, pos, size] = [entity.aoi, entity.position, entity.size];
				if (aoi.checkPfc()) {
					let res = !camera.entity ? true : (camera.aoiW >= Math.abs(pos.x - camera.entity.position.x) * 2 - size.w)
						&& (camera.aoiH >= Math.abs(pos.y - camera.entity.position.y) * 2 - size.h);
					entity.aoi.active = res;
				}
			});
		}
	}
}